package com.itheima.reggie;

/**
 * ThreadLocal
 */
public class ThreadLocalDemo {

    public static ThreadLocal<String> LOCAL = new ThreadLocal<>();

    public static void main(String[] args) {

        LOCAL.set("Main Message");

        String result = LOCAL.get();
        System.out.println("result:"+result);


        new Thread(new Runnable() {
            @Override
            public void run() {
                LOCAL.set("Sub Message");

                String s = LOCAL.get();
                System.out.println("s: " + s);
            }
        }).start();



        String result2 = LOCAL.get();
        System.out.println("result2: "+result2);



//        LOCAL.remove();
//
//        String result2 = LOCAL.get();
//        System.out.println(result2);

    }

}
